Skip to content

fix: correct default branch detection and ensure consistent scanning … #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2025

Conversation

dacoburn
Copy link
Collaborator

…behavior

Root Cause

Forced API Mode for non manifest file changes in a Git Repo was not correctly setting/using the default branch.

Fix

FIXED BUGS:

  • Default branch detection was not working properly in git repositories
  • make_default_branch and set_as_pending_head were inconsistently set
  • CLI would skip scans when manifest files hadn't changed (should always scan)
  • --default-branch flag was being overridden by SCM detection
  • GitLab CI integration wasn't detecting default branch correctly

CORRECTED BEHAVIOR:

  • Always perform scans regardless of manifest file changes (API mode when no manifests changed)
  • Proper default branch detection priority system:
    1. Explicit --default-branch flag (highest priority)
    2. CI environment variables (GitHub Actions, GitLab CI)
    3. Git repository analysis via git_repo.is_default_branch
    4. Fallback to false
  • Both make_default_branch and set_as_pending_head now synchronized correctly
  • Force API mode enables non-blocking behavior when no manifest files changed

ENHANCED AUTO-DETECTION:

  • Repository name from git remote origin (was manual)
  • Branch, commit SHA, message, and committer from git (was manual)
  • Changed files from git commit (was manual)
  • Better error handling for non-git repositories

SIMPLIFIED CI/CD USAGE:

  • Most parameters now optional due to git auto-detection
  • Added production-ready workflow examples:
    • workflows/github-actions.yml - GitHub Actions with concurrency control
    • workflows/gitlab-ci.yml - GitLab CI with environment detection
    • workflows/bitbucket-pipelines.yml - Bitbucket with path filtering
  • Updated README with corrected parameter documentation

The CLI now works as users expected:

  • GitHub: socketcli --target-path --scm github --pr-number
  • GitLab: socketcli --target-path --scm gitlab --pr-number
  • Local: socketcli --target-path ./project

Public Changelog

  • Default branch detection was not working properly in git repositories
  • make_default_branch and set_as_pending_head were inconsistently set
  • CLI would skip scans when manifest files hadn't changed (should always scan)
  • --default-branch flag was being overridden by SCM detection
  • GitLab CI integration wasn't detecting default branch correctly

…behavior

FIXED BUGS:
- Default branch detection was not working properly in git repositories
- make_default_branch and set_as_pending_head were inconsistently set
- CLI would skip scans when manifest files hadn't changed (should always scan)
- --default-branch flag was being overridden by SCM detection
- GitLab CI integration wasn't detecting default branch correctly

CORRECTED BEHAVIOR:
- Always perform scans regardless of manifest file changes (API mode when no manifests changed)
- Proper default branch detection priority system:
  1. Explicit --default-branch flag (highest priority)
  2. CI environment variables (GitHub Actions, GitLab CI)
  3. Git repository analysis via git_repo.is_default_branch
  4. Fallback to false
- Both make_default_branch and set_as_pending_head now synchronized correctly
- Force API mode enables non-blocking behavior when no manifest files changed

ENHANCED AUTO-DETECTION:
- Repository name from git remote origin (was manual)
- Branch, commit SHA, message, and committer from git (was manual)
- Changed files from git commit (was manual)
- Better error handling for non-git repositories

SIMPLIFIED CI/CD USAGE:
- Most parameters now optional due to git auto-detection
- Added production-ready workflow examples:
  - workflows/github-actions.yml - GitHub Actions with concurrency control
  - workflows/gitlab-ci.yml - GitLab CI with environment detection
  - workflows/bitbucket-pipelines.yml - Bitbucket with path filtering
- Updated README with corrected parameter documentation

The CLI now works as users expected:
- GitHub: socketcli --target-path  --scm github --pr-number
- GitLab: socketcli --target-path  --scm gitlab --pr-number
- Local: socketcli --target-path ./project
@dacoburn dacoburn added the Product Changelog New features for the public changelog label Jul 25, 2025
@dacoburn dacoburn requested a review from a team as a code owner July 25, 2025 00:48
@dacoburn dacoburn requested review from kapravel and Planeshifter and removed request for a team July 25, 2025 00:48
Copy link

🚀 Preview package published!

Install with:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==2.1.24.dev1

Docker image: socketdev/cli:pr-102

@dacoburn dacoburn merged commit 8faf84a into main Jul 25, 2025
6 checks passed
@dacoburn dacoburn deleted the doug/fix-default-branch-no-manifest-change branch July 25, 2025 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Product Changelog New features for the public changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants